<!doctype html>
<html lang="en"><head>
    <meta charset="utf-8">
    <title>系统后台登录</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="stylesheet" type="text/css" href="/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.css">

    <script src="/lib/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/lib/jquery.validate.js" type="text/javascript"></script>
    {{--<script src="/js/login.js" type="text/javascript"></script>--}}

    <link rel="stylesheet" type="text/css" href="/css/theme.css">
    <link rel="stylesheet" type="text/css" href="/css/premium.css">
</head>
<body class=" theme-blue">

<!-- Demo page code -->

<script type="text/javascript">
    $(function() {
        var match = document.cookie.match(new RegExp('color=([^;]+)'));
        if(match) var color = match[1];
        if(color) {
            $('body').removeClass(function (index, css) {
                return (css.match (/\btheme-\S+/g) || []).join(' ')
            })
            $('body').addClass('theme-' + color);
        }

        $('[data-popover="true"]').popover({html: true});

    });
</script>
<style type="text/css">
    #line-chart {
        height:300px;
        width:800px;
        margin: 0px auto;
        margin-top: 1em;
    }
    .navbar-default .navbar-brand, .navbar-default .navbar-brand:hover {
        color: #fff;
    }
</style>

<script type="text/javascript">
    $(function() {
        var uls = $('.sidebar-nav > ul > *').clone();
        uls.addClass('visible-xs');
        $('#main-menu').append(uls.clone());
    });
</script>
<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->

<div class="navbar navbar-default" role="navigation">
    <div class="navbar-collapse collapse" style="height: 1px;">
    </div>
</div>
</div>



<div class="dialog">
    <div class="panel panel-default">
        <p class="panel-heading no-collapse">后台管理系统</p>
        <div class="panel-body">
            <form id="loginForm">
                <div class="form-group">
                    <label>用户名</label>
                    <input type="text" name="name" class="form-control span12">
                    <label id="name-error" class="error" for="name"></label>
                </div>
                <div class="form-group">
                    <label>密码</label>
                    <input type="password" class="form-controlspan12 form-control" name="password">
                    <label id="password-error" class="error" for="password" style="display: inline-block;"></label>
                </div>
                <a onclick="userLogin()" class="btn btn-primary pull-right">登录</a>
                <label class="remember-me"><input type="checkbox" name="remember"> 记住我</label>
                <div class="clearfix"></div>
            </form>
        </div>
    </div>
    {{--<p class="pull-right" style=""><a href="#" target="blank" style="font-size: .75em; margin-top: .25em;">Design by Portnine</a></p>--}}
    {{--<p><a href="reset-password.html">Forgot your password?</a></p>--}}
</div>



<script src="lib/bootstrap/js/bootstrap.js"></script>
<script>
    $(document).keydown(function(event){
        if(event.keyCode == 13){
            $("#loginForm").submit();
        }
    });
    function userLogin() {
        $("#loginForm").submit();
    }
    $("#loginForm").validate({
            onsubmit: true,// 是否在提交是验证
            rules: {
                name: "required",
                password: "required",
            },
            messages: {
                name: "请输入用户手机号或邮箱",
                password: "请输入用户密码",

            },
            submitHandler: function (form) {
                login();
            }
        });

    function login(){
        var name = $("input[name='name']").val();
        var password = $("input[name='password']").val();
        var remember = $("input[name='remember']").val();
        var token = "{{csrf_token()}}";
        var data = {name:name,password:password,_token:token,remember:remember};

        $.ajax({
            data:data,
            type:'POST',
            url:'/auth/login',
            dataType:'json',
            success:function(data){
                if(data.code==0){
                    window.location.href='/';
                }
                if(data.code==1){
                    $("#name-error").css('display','block').text(data.message);
                }
                if(data.code==2 || data.code==3){
                    $("#password-error").css('display','block').text(data.message);
                }

            }
        })
    }
</script>
</body>
</html>
